package bg.cinema_system.beans;

import java.sql.Time;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Test {
	
	private static String converUtilDateToSqlDate(java.util.Date utilDate) {
	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	    String sqlDate = sdf.format(utilDate);
	    return sqlDate;
	}
	private static String converUtilDateToSqlDateString(String utilDate) throws ParseException {
	    Date data = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(utilDate);
	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	    String sqlDate = sdf.format(data);
	    return sqlDate;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Time sqlTime;
		String durationString = "2012-10-25 2:15:30";
		Date date = null;
		try {
			date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(durationString);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		System.out.println(date);
//		Date date = null;
//		try {
//			date = new SimpleDateFormat("HH:mm:ss").parse(durationString);
//		} catch (ParseException e) {
//			
//			e.printStackTrace();
//		}
//		sqlTime = new java.sql.Time(date.getTime()); 
//		System.out.println(">>>>>>" + sqlTime + "<<<<<<<");
		
//		System.out.println(date);
//		System.out.println(converUtilDateToSqlDate(date));
//		try {
//			System.out.println(converUtilDateToSqlDateString("2013-01-20 22:04:52"));
//		} catch (ParseException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		java.util.Calendar cal = Calendar.getInstance();
//		java.util.Date utilDate = new java.util.Date(); // your util date
//		cal.setTime(utilDate);
//		java.sql.Date sqlDate = new java.sql.Date(cal.getTime().getTime()); // your sql date
//		System.out.println("utilDate:" + utilDate);
//		System.out.println("sqlDate:" + sqlDate);
 	}

}
